import 'package:flutter/material.dart';

import 'home.dart';
import 'find.dart';
import 'market.dart';
import 'my.dart';

class Entry extends StatefulWidget {
  const Entry({super.key});

  @override
  State<Entry> createState() => _EntryState();
}

class _EntryState extends State<Entry> {
  int _currentIndex = 0;

  List<Widget> navbarItems = [
    const Home(),
    const Market(),
    const Find(),
    const My(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: navbarItems.elementAt(_currentIndex),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        unselectedItemColor: Colors.black,
        fixedColor: Colors.blueAccent,
        showUnselectedLabels: true,
        onTap: (int i) {
          setState(() {
            _currentIndex = i;
          });
        },
        items: const [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: "Home",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.card_giftcard),
            label: "Market",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.find_in_page),
            label: "Find",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person),
            label: "My",
          )
        ],
      ),
    );
  }
}
